package com.wnxy.mallserver.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;

@Data
public class User {
    private Integer id;
    private String account;
    @JsonIgnore//在对象与json互转时，忽略该属性
    private String password;
    private String avatar;
    private String cellphone;
    private String email;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime registdate;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private  LocalDateTime lastlogin;
    private  String state;

    //在setter方法中对cellphone进行脱敏处理
    public void setCellphone(String cellphone){
        String regex = "(\\d{3})\\d{4}(\\d{4})";
        String replacement = "$1****$2";
        this.cellphone = cellphone.replaceAll(regex, replacement);
    }
}








